﻿@using System.Diagnostics
@using Ecommerce.Models
@using Library
@using Library.Models
@model Product

@{
    ViewBag.Title = string.Format("{0} \"{1}\"", NOWCulture.GetString("Specifications"), (Model.ProductCultures.SingleOrDefault(i => i.Culture == NOWCulture.CurrentCulture) ?? Model.ProductCultures.First()).Name);
    Layout = "_Layout.cshtml";

    var specificationGroups = ViewBag.SpecificationGroups as IOrderedEnumerable<SpecificationGroup>;
    Debug.Assert(specificationGroups != null, "specificationGroups != null");

    var productSpecifications = ViewBag.ProductSpecifications as ProductViewModel.ProductSpecification[];
}

<h2>@ViewBag.Title</h2>
<form id="product-specifications" data-id="@Model.Id">
    <div class="pull-left">
        <a class="btn btn-warning" href="@Url.Action("Products")" title="@NOWCulture.GetString("Go back")"><span class="glyphicon glyphicon-arrow-left"></span> @NOWCulture.GetString("Go back")</a>
    </div>
    <div class="pull-right">
        <input type="reset" class="btn btn-default" value="@NOWCulture.GetString("Reset")">
        <input type="submit" class="btn btn-primary" value="@NOWCulture.GetString("Save")">
    </div>
    <div class="clearfix"></div>
    <div class="table-responsive">
        <table class="table table-hover" id="specification-groups">
            <thead>
                <tr>
                    <th>@NOWCulture.GetString("Specification name")</th>
                    <th>&nbsp;</th>
                </tr>
            </thead>
            <tbody id="tbody">
                @foreach (var specificationGroup in specificationGroups)
                {
                    @Html.Partial("_ProductSpecificationGroupRow", specificationGroup, new ViewDataDictionary()
                    {
                        new KeyValuePair<string, object>("productSpecifications", productSpecifications)
                    })
                }
            </tbody>
        </table>
    </div>
    <div class="pull-left">
        <a class="btn btn-warning" href="@Url.Action("Products")" title="@NOWCulture.GetString("Go back")"><span class="glyphicon glyphicon-arrow-left"></span> @NOWCulture.GetString("Go back")</a>
    </div>
    <div class="pull-right">
        <input type="reset" class="btn btn-default" value="@NOWCulture.GetString("Reset")">
        <input type="submit" class="btn btn-primary" value="@NOWCulture.GetString("Save")">
    </div>
    <div class="clearfix"></div>
</form>
@section styles
{
    @(HttpContext.Current.IsDebuggingEnabled ? Styles.Render("~/Content/admin-edit-product-specifications") : Scripts.RenderFormat(@"<link href=""{0}"" rel=""stylesheet"" />", "~/Content/admin-edit-product-specifications"))
}
@section scripts
{
    @(HttpContext.Current.IsDebuggingEnabled ? Scripts.Render("~/bundles/admin-edit-product-specifications") : Scripts.RenderFormat(@"<script src=""{0}"" async defer></script>", "~/bundles/admin-edit-product-specifications"))
}
